package service;

import models.Friends;
import models.Member;
import play.mvc.Scope;

public class MemberService {

	public static Member ckLogin(Scope.Session session){
		Member m = null;
		try{
			String userid = session.get("userid");
			m = Member.findById(Long.parseLong(userid));
		}catch(Exception e){}
		return m;
	}
	
	public static Member finauser(Long tomemid){
		Member m = null ;
		try{
			m = Member.findById(tomemid);
		}catch(Exception e){
			e.printStackTrace();
		}
		return m ;
	}
	
	public static Member findmem(String memid){
		Member m = null ;
		try{
			m = Member.findById(Long.parseLong(memid));
		}catch(Exception e){
			e.printStackTrace();
		}
		return m ;
	}
	
	public static Member findmember(String uname){
		Member meb = null ;
		meb = Member.find("from Member where memname = ? ", uname).first();
		return meb ;
	}
	
	public static Friends ckfriends(Long pid ,Long fid){
		Friends friends= null ;
		friends = Friends.find("from Friends where pid = ? and fid = ?", pid,fid).first() ;
		return friends;
	}
	
	
}
